local quhu = fk.CreateSkill{
  name = "iberia__quhu",
}

Fk:loadTranslationTable{
  [quhu.name] = "驱虎",
  [":"..quhu.name] = "出牌阶段限一次，你可以展示一张手牌并令两名折冲角色拼点：赢的角色对没赢的角色造成1点伤害，获得展示的牌。",
  ["#"..quhu.name] = "驱虎：可以展示一张手牌并令两名折冲角色拼点"
}

local I = require "packages/iberia/utility"

quhu:addEffect("active", {
  anim_type = "control",
  prompt = "#"..quhu.name,
  can_use = function (self, player)
    return not player:isKongcheng() and player:usedSkillTimes(quhu.name, Player.HistoryPhase) < 1
  end,
  card_num = 1,
  target_num = 2,
  card_filter = function (self, player, to_select, selected)
    return Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand
  end,
  target_filter = function (self, player, to_select, selected)
    if not S.isRepeller(to_select) then return false end
    if #selected == 0 then
      return not to_select:isKongcheng()
    elseif #selected == 1 then
      return selected[1]:canPindian(to_select)
    else
      return false
    end
  end,
  on_use = function (self, room, effect)
    local player = effect.from
    local cards = effect.cards
    local from, to = table.unpack(effect.tos)
    room:showCards(cards, player)
    if not from:canPindian(to) then return end
    local pd = from:pindian({to}, quhu.name)

    local winner = pd.results[to].winner
    if winner then
      local loser = (winner == from and to) or from
      room:damage{
        damage = 1,
        from = winner,
        to = loser,
        skillName = quhu.name,
      }

      cards = table.filter(cards, function(id) return table.contains(player:getCardIds("h"), id) end)
      if winner.dead or #cards == 0 then return end
      room:obtainCard(winner, cards, true, fk.ReasonPrey, winner, quhu.name)
    end
  end
})

return quhu